//
//  JsAnimationExecutorB.m
//  MpaClientIos
//
//  Created by Gikki Ares on 2023/4/21.
//  Copyright © 2023 Yach. All rights reserved.
//

#import "JsAnimationExecutorB.h"

@implementation JsAnimationExecutorB


+ (instancetype)sharedInstance {
	static JsAnimationExecutorB * _sharedInstance;
	static dispatch_once_t onceToken;
	dispatch_once(&onceToken, ^{
		_sharedInstance = [[JsAnimationExecutorB alloc]init];
	});
	return _sharedInstance;
}

- (void)rotateView:(UIView *)view atSpeed:(float)speed {
	CABasicAnimation* rotationAnimation;
	rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
	rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
	rotationAnimation.duration = 0.8;
	rotationAnimation.cumulative = YES;
	rotationAnimation.repeatCount = ULLONG_MAX;
	rotationAnimation.removedOnCompletion = NO;
	[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}

- (void)stopRotate:(UIView *)view {
	[view.layer removeAllAnimations];
}

- (void)shake {
//
//		CAKeyframeAnimation *anima = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];//在这里@"transform.rotation"==@"transform.rotation.z"
//
//		NSValue *value1 = [NSNumber numberWithFloat:-M_PI/180*4];
//
//		NSValue *value2 = [NSNumber numberWithFloat:M_PI/180*4];
//
//		NSValue *value3 = [NSNumber numberWithFloat:-M_PI/180*4];
//
//			//    如果把动画的duration设置为3秒，而speed设置为2，动画将会在1.5秒结束，因为它以两倍速在执行。
//
//			//    anima.duration = 2.0f;
//
//			// anima.repeatCount = MAXFLOAT;
//		anima.values = @[value1,value2,value3];
//
//			//速度
//		anima.speed = 1;
//
//			//重复次数
//		anima.repeatCount = 3;
//
//		[_demoView.layer addAnimation:anima forKey:@"shakeAnimation"];
//
//	}
}

@end
